package client.comm.baoding.ui

import android.view.View
import androidx.navigation.fragment.NavHostFragment
import client.comm.baoding.BaseMiddleActivity
import client.comm.baoding.R
import client.comm.baoding.databinding.ActivityMyGuadanBinding
import client.comm.baoding.ui.vm.TradeDetailModel

/**
 * 我的挂单
 */
class MyGuaDanActivity : BaseMiddleActivity<TradeDetailModel, ActivityMyGuadanBinding>() {

    var goods_id: String? = null
    var isTabGone: Boolean = false

    override fun getLayout(): Int {
        return R.layout.activity_my_guadan
    }

    override fun initViewModel(): TradeDetailModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel

        goods_id = intent.getStringExtra("goodsId")
    }

    fun clickTab(index: Int) {
        updateTab(index)

    }

    fun updateTab(index: Int) {
        when (index) {
            1 -> {
                binding.oneTab.isSelected = true
                binding.twoTab.isSelected = false
//                binding.one.visibility = View.VISIBLE
//                binding.two.visibility = View.GONE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.oneTab
                )
            }
            0 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = true
//                binding.one.visibility = View.GONE
//                binding.two.visibility = View.VISIBLE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.twoTab
                )
            }

        }
    }

    override fun initData() {
        updateTab(intent.getIntExtra("index", 0))
    }

}